import axios from 'axios'

const request = axios.create({
  baseURL: 'http://api.tianapi.com/txapi',
  timeout: 6000
})

// 异常拦截处理器
const errorHandler = (error: any) => {
  return error
}

// request interceptor
request.interceptors.request.use(config => {
  config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
  return config
}, errorHandler)

// response interceptor
request.interceptors.response.use((response) => {
  return response.data
}, errorHandler)

export default request
